  import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import path from 'path'

export default defineConfig({
  /*build: {
    rollupOptions: {
      input: {
        index: path.resolve(__dirname, 'index1.html'),
      },
    },
  },*/
  plugins: [
    vue(),
    Components({
      resolvers: [
        ElementPlusResolver({
          importStyle: 'sass',
          // directives: true,
          // version: "2.1.5",
        }),
      ],
      directoryAsNamespace: true,
    }),
  ],
  css: {
    preprocessorOptions: {
      scss: {
        additionalData:
          '@use "@/styles/element.scss" as *; @use "@/styles/variable.scss" as *;', //引入多个
      },
    },
  },
  resolve: {
    alias: {
      '@': path.resolve('./src'), // 相对路径别名配置，使用 @ 代替 src
    },
  },
  server: {
    proxy: {
      '/devApi/file': {
        target: 'http://122.51.80.75', // 目标服务器地址
        changeOrigin: true, // 支持跨域
        rewrite: (path) => path.replace(/^\/devApi/, ''), // 重写路径
      },
      '/devApi': {
        target: 'http://122.51.80.75:40001', // 目标服务器地址
        changeOrigin: true, // 支持跨域
        rewrite: (path) => path.replace(/^\/devApi/, ''), // 重写路径
      },
    },
  },
})
